//Disposeable Mixin
class Disposable {
	isDisposed: boolean;
	dispose() {
		this.isDisposed = true;
	}
}

//Activatable Mixin
class Activatable {
	isActive: boolean;
	activate() {
		this.isActive = true;
	}
	deactivate() {
		this.isActive = false;
	}
}

class SmartObject implements Disposable, Activatable {
	constructor() {
		setInterval(() => console.log(`${this.isDisposed} : ${this.isActive}`), 500);
	}
	interact() {
		this.activate();
	}
	isDisposed: boolean = false;
	dispose: () => void;
	isActive: boolean = false;
	activate: () => void;
	deactivate: () => void;
}


function applyMixins(derivedCtor: any, baseCtors: any[]) {
	baseCtors.forEach(baseCtor=> {
		Object.getOwnPropertyNames(baseCtor.prototype).forEach(name=> {
			derivedCtor.prototype[name] = baseCtor.prototype[name];
		});
	});
}

applyMixins(SmartObject, [Disposable, Activatable]);

var smartObj = new SmartObject();
setTimeout(()=>smartObj.interact(),1000);
